package com.chery.media.app

import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.Utils
import com.chery.media.BuildConfig
import com.chery.media.library.base.BaseApplication
import com.chery.media.library.extend.initMMkv
import com.chery.media.library.router.Router
import com.chery.media.ui.mediaViewModel
import com.mallotec.reb.localeplugin.LocaleConstant
import com.mallotec.reb.localeplugin.LocalePlugin
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import me.jessyan.autosize.AutoSize
import me.jessyan.autosize.AutoSizeConfig

class MyApplication : BaseApplication() {

    companion object {
        init {
            SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, _ ->
                ClassicsHeader(context)
            }
        }
    }


    override fun onCreate() {
        super.onCreate()
        /*MVVMLin.setNetException(CoroutineExceptionHandler { context, e ->

        })*/
        Utils.init(this)
        LogUtils.getConfig().run {
            isLogSwitch = BuildConfig.DEBUG
            setSingleTagSwitch(true)
        }
        AutoSize.initCompatMultiProcess(this)
        AutoSizeConfig.getInstance().apply {
            isCustomFragment = true
            isBaseOnWidth = true
            setLog(true)
        }
        initMMkv(this)
        mediaViewModel.startGetTime()
        LocalePlugin.init(this, LocaleConstant.RESTART_TO_LAUNCHER_ACTIVITY)
        Router.init(Router.RES_NONE, Router.RES_NONE, Router.RES_NONE, Router.RES_NONE)
    }
}